package org.joy.controller;


import org.joy.data.Book;
import org.joy.data.BookRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class BookController {
    @Autowired
    private BookRepository bookRepository;
//
//    @PostMapping("/book")
//    public void save(@RequestBody Book book) {
//        bookRepository.save(book);
//    }
//
//    @GetMapping("/book/{id}")
//    public Book findById(@PathVariable String id) {
//        return bookRepository.findById(id).orElse(null);
//    }

    @GetMapping("/book/title/{title}")
    public List<Book> findByTitle(@PathVariable String title) {
        return bookRepository.findByTitle(title);
    }
}
